home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-12-08 | 2.0 KB | 86 lines | [TEXT/GEOL] |
- Item 9074393 7-Dec-89 12:17
-
- From: D1950 CSG, Don Phillips,PRT
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: Failure Handling
-
- Geoff and Jeff,
-
- Thanks for your explanations. I have another question regarding Failure
- Handlers. This time it's not in an initialization method.
-
- What is the best way to implement Failure Handling in the situation below?
-
- Is there somewhere in the documentation that I can find this type of
- information?
-
- Thanks again,
- Jo-Anne Droogh
-
-
- TTObject4.DoSomethingOtherThanInitialization;
-
- VAR
- tmpObject1 : TTObject1;
- tmpObject2 : TTObject2;
- tmpObject3 : TTObject3;
- fi1 : FailInfo;
- fi2 : FailInfo;
- fi3 : FailInfo;
-
- PROCEDURE LocalFailureHandler1( error : OSErr; message : LONGINT );
-
- BEGIN
- FreeIfObject( tmpObject1 );
- END;
-
- PROCEDURE LocalFailureHandler2( error : OSErr; message : LONGINT );
-
- BEGIN
- FreeIfObject( tmpObject2 );
- END;
-
- PROCEDURE LocalFailureHandler3( error : OSErr; message : LONGINT );
-
- BEGIN
- FreeIfObject( tmpObject3 );
- END;
-
- BEGIN
- tmpObject1 := NIL;
- tmpObject2 := NIL;
- tmpObject3 := NIL;
-
- New( tmpObject1 );
- FailNIL( tmpObject1 );
- tmpObject1.IObject1; { If this fails, it will be freed }
-
- CatchFailures( fi1, LocalFailureHandler1 );
-
- { Do something that could fail. }
-
- New( tmpObject2 );
- FailNIL( tmpObject2 );
- tmpObject2.IObject2; { If this fails, it will be freed }
-
- CatchFailures( fi2, LocalFailureHandler2 );
-
- { Do something that could fail. }
-
- New( tmpObject3 );
- FailNIL( tmpObject3 );
- tmpObject3.IObject3; { If this fails, it will be freed }
-
- CatchFailures( fi3, LocalFailureHandler3 );
-
- { Do something that could fail. }
-
- Success( fi3 ); { Order matters here. }
- Success( fi2 );
- Success( fi1 );
-
- END;
-
-